<?php
/**
 * <https://y.st./>
 * Copyright © 2016 Alex Yst <mailto:copyright@y.st>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org./licenses/>.
**/

$xhtml = array(
	'<{title}>' => "Learning about the <code>ircs:</code> $a[URI] scheme",
	'<{body}>' => <<<END
<p>
	I have been dealing with an ear infection over the past few days, and it has been worrying me quite a bit.
	I have been told that ear infections require treatment.
	I did some research online, and the results backed up my fear.
	They all said that antibiotics are required, but the health insurance people still have not gotten back to me.
	I decided to rephrase my search.
	Instead of asking what needs to be done about ear infections, I asked about what happens if ear infections are not treated.
	Mostly, the results were much more reassuring.
	As it turns out, medical professionals often say to wait out ear infections instead of prescribing antibiotics in an effort to avoid having the bacteria build up a resistance to the antibiotics.
	If I went to see a doctor, there is a good chance that I would not be prescribed anything anyway.
	Furthermore, ear infections appear to be common right after having caught a cold, and I have just gotten over one.
	The bacteria in my ear is likely just common cold bacteria and is likely nothing more than annoying.
	I also learned about the anatomy of the ear and why I do not seem to be able to drain the liquid I feel in there; it is behind the ear drum.
	There is a drainage tube leading from the liquid chamber behind the ear drum to the throat, but when this tube becomes swollen, liquid cannot drain and it becomes a cesspool.
	In some cases, this buildup can lead to a rupture of the ear drum.
	This sounds painful, but according to what the Internet said, it actually brings relief to the pain, as the liquid can drain, then the ear drum heals later.
	This makes a lot more sense, as it seems like it would have been quite difficult for the human species to survive before medication existed if something as small as an ear infection was likely to be highly hazardous.
	Evolution would have favored those that could survive with minimal damage.
	On the other hand, there was some worrying news too.
	One site said that there is an eighty percent chance that an ear infection will clear up without complications.
	Of course, I read that as there being a twenty percent chance of complications.
	I find that percentage to be alarmingly high! Another site mentioned that sometimes, an ear infection can lead to a brain infection, which would not be good news at all.
</p>
<p>
	Though I am feeling under the weather, it seems that our cat is feeling a lot better.
	She has been much more active and much less mopey lately.
</p>
<p>
	I headed out to get help with the government health insurance application in-person, fearing that my mailed-in application had been silently ignored.
	I made it most of the way to the building of the company that the government health care website said could help with little difficulty, but the street addresses on that street are screwy.
	I got to one spot in which the addresses went down in both directions.
	Confused, I had to stop and ask for directions.
	Once I got there, I found that the official government health care website had lied.
	I had walked out past the edge of the far end of town for nothing.
	These people were not able to help.
	The trip was not a complete bust though, I suppose.
	The man there did have some useful information.
	First, he explained that when he applied for coverage, it took two months for them to respond, and that was during their off season.
	I only applied a little over a month ago, an now is their busy season.
	Second, there is a clinic a lot closer to my home that can help with the application.
	I still want to try submitting in person, just to be safe.
</p>
<p>
	By altering my route a bit, I was able to pass by very close to the clinic on the way home, so I made a slight detour and stopped by the clinic.
	They were unable to help with the application right away, but they had me register with the clinic and set up an appointment for Monday.
	Monday is the day after the application is due though, so I do not know how helpful that will be.
	Hopefully either the mailed-in application or the day-late application will be accepted though.
</p>
<p>
	I found a flaw in the regular expression mentioned in <a href="https://tools.ietf.org/html/rfc3986">$a[RFC] 3986</a>.
	This regular expression works perfectly if the $a[URI] that is being parsed is known to be valid, but I malformed $a[URI]s with blank schemes will cause the scheme&apos;s delimiter, the colon, to be interpreted as the authority and causes the double slash delimitor and the authority to be interpreted as part of the path.
	I built my own regular expression to fix this issue, and my new regular expression additionally parses the userdata, host, and port out of the authority component.
	My new <code>parse_uri()</code> function will now return a similar array as $a[PHP]&apos;s <a href="https://secure.php.net/manual/en/function.parse-url.php"><code>\\parse_url()</code> function</a>, but with a few key differences.
	First and formost, <code>\\parse_url()</code>&apos;s documentation says that it does not work on general $a[URI]s and does not work on relative $a[URI]s.
	However, <code>parse_uri()</code> is designed explicitly to work with all $a[URI]s that conform to the general syntax, including relative $a[URI]s.
	Second, <code>parse_uri()</code> will by default call another function, <code>normalize_uri()</code>.
	This function will perform any normalizations needed, and also throw an exception if a $a[URI]&apos;s components are invalid.
	To deal with invalid $a[URI]s, <code>parse_uri()</code> can be told with an argument to avoid normalization.
	Last, and least importantly, <code>parse_uri()</code> does not have &quot;user&quot; and &quot;pass&quot; keys in its returned array.
	Instead, it has a unified &quot;userinfo&quot; key, as the general $a[URI] syntax does not split up the userinfo into user and password information.
	This separation is left for specific $a[URI] schemes to implement in whatever way they decide to.
</p>
<p>
	Having learned more about $a[URI]s, I now know that the default port used by a $a[URI] with no explicitly-set port is not set by the <a href="https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml">port registry</a>.
	Instead, the default port for a $a[URI] is defined by the scheme&apos;s definition.
	If I am going to set up the function to normalize $a[URI]s, I am going to need to know the port numbers associated with each scheme, so I looked up the <a href="https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml">scheme registry</a>.
	I was curious about the defined default for the <code>ircs:</code> and <code>irc:</code> schemes, as many ports are used for both protocols.
	It turns out that <a href="https://tools.ietf.org/html/draft-butcher-irc-url-04#section-2.4">the <code>ircs:</code> scheme uses the official $a[IRCS] port assigned by $a[IANA] as its default, but the <code>irc:</code> scheme uses one of the newer alternative ports allowed by $a[IANA]</a>.
	This seems inconsistent to me.
	More importantly though, it means that I need to fix all the links to $a[IRC] networks in my weblog.
	I assumed port 6697 as the default, but port 994 is the real default, so I need to correct my hyperlinks to explicitly specify a port.
</p>
<p>
	It also seems that the fragment of a $a[URI] is delimited by the pound symbol, but cannot contain pound symbols.
	This lead to more questions for me in regards to the <code>ircs:</code> scheme.
	First, that means when using the $a[URI] <code>ircs://example.com/#channel</code>, it should be interpreted as having a fragment of <code>channel</code>, which as it does not contain the pound symbol, is not a complete channel name.
	Second, the $a[URI] <code>ircs://example.com/#channel,#otherchannel</code> should be invalid, as it has two pound symbols.
	This also means that links to channels not beginning in a pound symbol, while rare, will be interpreted as path data, while channels beginning in a pound symbol will be interpreted as the presence of a fragment, as well as the data contained in the fragment.
	I found several interesting things though.
	First, the syntax used to link to multiple channels using a single $a[URI] is invalid.
	The <a href="https://tools.ietf.org/html/draft-butcher-irc-url-04#section-2.1">official syntax</a> simply does not work that way.
	Second, the <code>ircs:</code> and <code>irc:</code> schemes treat <a href="https://tools.ietf.org/html/draft-butcher-irc-url-04#section-2.5.1">unencoded pound signs</a> as <a href="https://tools.ietf.org/html/draft-butcher-irc-url-04#section-3">equivalent to encoded pound signs</a>.
	This means that a general-purpose $a[URI] parser will interpret channel names as part of the path or as the beginning of the fragment depending on if the pound sign is encoded or not, but an <code>ircs:</code>/<code>irc:</code> scheme-specific parser will not.
	I do not anticipate that this will cause issues for my parser though, as long as $a[URI]s still conform to the <code>ircs:</code>/<code>irc:</code> scheme specification, as only one channel name is allowed per $a[URI], so only one pound sign, if any, should be present.
	Invalid $a[URI]s that try to point to multiple channels might cause issues though.
	Another interesting feature is that it is possible to <a href="https://tools.ietf.org/html/draft-butcher-irc-url-04#section-2.5.2">link to users</a> instead of channels.
	One thing that I do not like about this scheme though is that instead of an $a[IP] address or domain name, you can also link to an <a href="https://tools.ietf.org/html/draft-butcher-irc-url-04#section-2.3">unregistered pet name</a>.
	As long as everyone is using the same pet name list, that works, but using domain names is a much more reliable option.
</p>
<p>
	My <a href="/a/canary.txt">canary</a> still sings the tune of freedom and transparency.
</p>
END
);
